/**
 * Created by Dalyn on 2017/5/8.
 * 缝制辅料
 */
import React from "react";
import {hashHistory} from 'react-router';
import Relay from "react-relay";
import { notification, message,Input, Icon, Button, Popconfirm } from 'antd';
import ReactKey from "../../../../util/ReactKey";
import OtherRequirementsItemLook from './OtherRequirementsItemLook';
import GetProOthersDetailMutation from '../mutation/otherRequireMutation/GetProOthersDetailMutation';
import "../css/otherRequirements.css";
import "../../css/productionManagement_common.css";

export default class SewRaw extends React.Component{
    constructor(props) {
        super(props);
        this.state = {
            token:"",
            dataSource:[],
            visible:"",
        };
        this.pdId = this.props.pdId;
    }
    componentWillMount(){
        this.getProOthersDetail();
    }
    /*要求数据请求*/
    getProOthersDetail(){
        Relay.Store.commitUpdate(
            new GetProOthersDetailMutation({
                pdId: this.props.pdId,
            }),
            {
                onFailure: () => {
                    message.error('网络请求失败');
                },
                onSuccess: (response) => {
                    let errorCode = response.getProOthersDetail.responseData.errorCode;
                    let value = response.getProOthersDetail.responseData.value;
                    if (errorCode == 0) {
                        let proOthersDetailModelList = response.getProOthersDetail.responseData.proOthersDetailModelList;
                        this.proOthersDetailModelList = proOthersDetailModelList;
                        this.setState({
                            dataSource: proOthersDetailModelList,
                        })
                    } else {
                        if (errorCode == 500){
                            message.error('服务器错误,请联系系统管理员');
                        }
                    }
                }

            }
        );
    }
    render(){
        const {dataSource,token} = this.state,
            {}  = this.props;
        return (
            <div className="" >
                <div className="poduction_otherRequ">
                    <div className="poduction_otherRequ_container">
                        {
                            dataSource && dataSource.length>0 ?(
                                dataSource.map((item,index)=>{
                                    return (
                                        <OtherRequirementsItemLook
                                            item={item}
                                            index={index}
                                            _token={token}
                                            key = {ReactKey.key}
                                        />
                                    )
                                })
                            ):(
                                <p className="production_look_empty">
                                    <i></i>
                                    <span>暂无数据</span>
                                </p>
                            )
                        }
                    </div>
                </div>
            </div>
        )
    }
}